<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
      
    
    
      
    
  <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
  <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-flash.min.css" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
    
  
  <link href="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet" type="text/css">







  

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="ts,">





  <link rel="alternate" href="/atom.xml" title="TiX" type="application/atom+xml">






<meta name="description" content="一篇记录ts学习历程的东东。">
<meta name="keywords" content="ts">
<meta property="og:type" content="article">
<meta property="og:title" content="记录ts的学习历程(二)">
<meta property="og:url" content="https://gitee.com/L1334101793/记录ts的学习历程-二/index.html">
<meta property="og:site_name" content="TiX">
<meta property="og:description" content="一篇记录ts学习历程的东东。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-03-04T07:33:56.633Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="记录ts的学习历程(二)">
<meta name="twitter:description" content="一篇记录ts学习历程的东东。">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"right","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://gitee.com/L1334101793/记录ts的学习历程-二/">





  <title>记录ts的学习历程(二) | TiX</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-right page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">TiX</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Stay Hungry, Stay Foolish</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/L1334101793/记录ts的学习历程-二/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="TiX">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="TiX">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">记录ts的学习历程(二)</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-03-04T14:03:18+08:00">
                2019-03-04
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/js/" itemprop="url" rel="index">
                    <span itemprop="name">js</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o">本文阅读</i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>人次
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>一篇记录ts学习历程的东东。<br><a id="more"></a></p>
<h3 id="typeScript中的类"><a href="#typeScript中的类" class="headerlink" title="typeScript中的类"></a>typeScript中的类</h3><h4 id="类的定义"><a href="#类的定义" class="headerlink" title="类的定义"></a>类的定义</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">class Person&#123;</span><br><span class="line">    name:string;   //属性  前面省略了public关键词</span><br><span class="line">    constructor(name:string)&#123;  //构造函数   实例化类的时候触发的方法</span><br><span class="line">        this.name=name;</span><br><span class="line">    &#125;</span><br><span class="line">    run():void&#123;</span><br><span class="line">        alert(this.name);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">var p=new Person(<span class="string">'张三'</span>);</span><br><span class="line">p.run()  <span class="comment">#张三</span></span><br></pre></td></tr></table></figure>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">class Person&#123;</span><br><span class="line">    name:string; </span><br><span class="line">    constructor(name:string)&#123;  //构造函数   实例化类的时候触发的方法</span><br><span class="line">        this.name=name;</span><br><span class="line">    &#125;</span><br><span class="line">    getName():string&#123;</span><br><span class="line">        <span class="built_in">return</span> this.name;</span><br><span class="line">    &#125;</span><br><span class="line">    setName(name:string):void&#123;</span><br><span class="line">        this.name=name;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">var p=new Person(<span class="string">'张三'</span>);</span><br><span class="line">alert(p.getName());  <span class="comment">#张三</span></span><br><span class="line">p.setName(<span class="string">'李四'</span>);</span><br><span class="line">alert(p.getName());  <span class="comment">#李四</span></span><br></pre></td></tr></table></figure>
<h4 id="ts中实现继承-extends、-super"><a href="#ts中实现继承-extends、-super" class="headerlink" title="ts中实现继承 extends、 super"></a>ts中实现继承 extends、 super</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">class Person&#123;</span><br><span class="line">    name:string;</span><br><span class="line">    constructor(name:string)&#123;</span><br><span class="line">        this.name=name;</span><br><span class="line">    &#125;</span><br><span class="line">    run():string&#123;</span><br><span class="line">        <span class="built_in">return</span> `<span class="variable">$&#123;this.name&#125;</span>在运动`</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">class Web extends Person&#123;</span><br><span class="line">    constructor(name:string)&#123;</span><br><span class="line">        super(name);  /*初始化父类的构造函数*/</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">var w=new Web(<span class="string">'李四'</span>);</span><br><span class="line">alert(w.run());  <span class="comment">#李四在运动</span></span><br></pre></td></tr></table></figure>
<h4 id="类里面的修饰符"><a href="#类里面的修饰符" class="headerlink" title="类里面的修饰符"></a>类里面的修饰符</h4><p>public :公有          在当前类里面、 子类  、类外面都可以访问<br>protected：保护类型    在当前类里面、子类里面可以访问 ，在类外部没法访问<br>private ：私有         在当前类里面可以访问，子类、类外部都没法访问<br>属性如果不加修饰符 默认就是 公有 （public）</p>
<h5 id="protected：保护类型-在类里面、子类里面可以访问-，在类外部没法访问"><a href="#protected：保护类型-在类里面、子类里面可以访问-，在类外部没法访问" class="headerlink" title="protected：保护类型  在类里面、子类里面可以访问 ，在类外部没法访问"></a>protected：保护类型  在类里面、子类里面可以访问 ，在类外部没法访问</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">class Person&#123;</span><br><span class="line">      protected name:string;  /*保护属性*/</span><br><span class="line">      constructor(name:string)&#123;</span><br><span class="line">          this.name=name;</span><br><span class="line">      &#125;</span><br><span class="line">      run():string&#123;</span><br><span class="line">          <span class="built_in">return</span> `<span class="variable">$&#123;this.name&#125;</span>在运动`</span><br><span class="line">      &#125;</span><br><span class="line">  &#125;</span><br><span class="line">  class Web extends Person&#123;</span><br><span class="line">      constructor(name:string)&#123;</span><br><span class="line">          super(name);  /*初始化父类的构造函数*/</span><br><span class="line">      &#125;                  </span><br><span class="line">      <span class="function"><span class="title">work</span></span>()&#123;</span><br><span class="line">          alert(`<span class="variable">$&#123;this.name&#125;</span>在工作`)</span><br><span class="line">      &#125;</span><br><span class="line">  &#125;</span><br><span class="line">  var w=new Web(<span class="string">'李四11'</span>);</span><br><span class="line">  w.work();</span><br><span class="line">  alert( w.run());</span><br></pre></td></tr></table></figure>
<h5 id="private-：私有-在类里面可以访问，子类、类外部都没法访问"><a href="#private-：私有-在类里面可以访问，子类、类外部都没法访问" class="headerlink" title="private ：私有  在类里面可以访问，子类、类外部都没法访问"></a>private ：私有  在类里面可以访问，子类、类外部都没法访问</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">class Person&#123;</span><br><span class="line">    private name:string;  /*私有*/</span><br><span class="line">    constructor(name:string)&#123;</span><br><span class="line">        this.name=name;</span><br><span class="line">    &#125;</span><br><span class="line">    run():string&#123;</span><br><span class="line">        <span class="built_in">return</span> `<span class="variable">$&#123;this.name&#125;</span>在运动`</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">class Web extends Person&#123;</span><br><span class="line">    constructor(name:string)&#123;</span><br><span class="line">        super(name)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">work</span></span>()&#123;</span><br><span class="line">        console.log(`<span class="variable">$&#123;this.name&#125;</span>在工作`)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="静态属性-静态方法"><a href="#静态属性-静态方法" class="headerlink" title="静态属性 静态方法"></a>静态属性 静态方法</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">class Per&#123;</span><br><span class="line">    public name:string;</span><br><span class="line">    public age:number=20;</span><br><span class="line">    static sex=<span class="string">"男"</span>;  <span class="comment">#静态属性</span></span><br><span class="line">    constructor(name:string) &#123;</span><br><span class="line">        this.name=name;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">run</span></span>()&#123;  /*实例方法*/</span><br><span class="line">        alert(`<span class="variable">$&#123;this.name&#125;</span>在运动`)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">work</span></span>()&#123;</span><br><span class="line">        alert(`<span class="variable">$&#123;this.name&#125;</span>在工作`)</span><br><span class="line">    &#125;</span><br><span class="line">    static <span class="function"><span class="title">print</span></span>()&#123;  /*静态方法，里面没法直接调用类里面的属性,可以调用静态属性*/</span><br><span class="line">        alert(<span class="string">'print方法'</span>+Per.sex);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="多态-父类定义一个方法不去实现，让继承它的子类去实现-每一个子类有不同的表现，多态属于继承"><a href="#多态-父类定义一个方法不去实现，让继承它的子类去实现-每一个子类有不同的表现，多态属于继承" class="headerlink" title="多态:父类定义一个方法不去实现，让继承它的子类去实现,每一个子类有不同的表现，多态属于继承"></a>多态:父类定义一个方法不去实现，让继承它的子类去实现,每一个子类有不同的表现，多态属于继承</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">class Animal &#123;</span><br><span class="line">    name:string;</span><br><span class="line">    constructor(name:string) &#123;</span><br><span class="line">        this.name=name;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">eat</span></span>()&#123;   //具体吃什么?不知道，具体吃什么?继承它的子类去实现 ，每一个子类的表现不一样</span><br><span class="line">        console.log(<span class="string">'吃的方法'</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">class Dog extends Animal&#123;</span><br><span class="line">    constructor(name:string)&#123;</span><br><span class="line">        super(name)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">eat</span></span>()&#123;</span><br><span class="line">        <span class="built_in">return</span> this.name+<span class="string">'吃粮食'</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">class Cat extends Animal&#123;</span><br><span class="line">    constructor(name:string)&#123;</span><br><span class="line">        super(name)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">eat</span></span>()&#123;</span><br><span class="line">        <span class="built_in">return</span> this.name+<span class="string">'吃老鼠'</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="typescript中的抽象类：它是提供其他类继承的基类，不能直接被实例化。"><a href="#typescript中的抽象类：它是提供其他类继承的基类，不能直接被实例化。" class="headerlink" title="typescript中的抽象类：它是提供其他类继承的基类，不能直接被实例化。"></a>typescript中的抽象类：它是提供其他类继承的基类，不能直接被实例化。</h4><p>用abstract关键字定义抽象类和抽象方法，抽象类中的抽象方法不包含具体实现并且必须在派生类中实现。<br>abstract抽象方法只能放在抽象类里面。<br>抽象类和抽象方法用来定义标准。标准：Animal 这个类要求它的子类必须包含eat方法<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">abstract class Animal&#123;</span><br><span class="line">    public name:string;</span><br><span class="line">    constructor(name:string)&#123;</span><br><span class="line">        this.name=name;</span><br><span class="line">    &#125;</span><br><span class="line">    abstract eat():any;  //抽象方法不包含具体实现并且必须在派生类中实现。</span><br><span class="line">    <span class="function"><span class="title">run</span></span>()&#123;</span><br><span class="line">        console.log(<span class="string">'其他方法可以不实现'</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">// var a=new Animal() /*错误的写法*/</span><br><span class="line"> </span><br><span class="line">class Dog extends Animal&#123;</span><br><span class="line">    //抽象类的子类必须实现抽象类里面的抽象方法</span><br><span class="line">    constructor(name:any)&#123;</span><br><span class="line">        super(name)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">eat</span></span>()&#123;</span><br><span class="line">        console.log(this.name+<span class="string">'吃粮食'</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">var d=new Dog(<span class="string">'小花花'</span>);</span><br><span class="line">d.eat();</span><br><span class="line">class Cat extends Animal&#123;</span><br><span class="line">    //抽象类的子类必须实现抽象类里面的抽象方法</span><br><span class="line">    constructor(name:any)&#123;</span><br><span class="line">        super(name)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">run</span></span>()&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">eat</span></span>()&#123;</span><br><span class="line">        console.log(this.name+<span class="string">'吃老鼠'</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">var c=new Cat(<span class="string">'小花猫'</span>);</span><br><span class="line">c.eat();</span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wcpay.png" alt="TiX 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.png" alt="TiX 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/ts/" rel="tag"># ts</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/记录ts的学习历程(一)/" rel="next" title="记录ts的学习历程(一)">
                <i class="fa fa-chevron-left"></i> 记录ts的学习历程(一)
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/记录ts的学习历程三/" rel="prev" title="记录ts的学习历程(三)">
                记录ts的学习历程(三) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">TiX</p>
              <p class="site-description motion-element" itemprop="description">个人学习记录，涉及前端，分享心得等。</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">21</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#typeScript中的类"><span class="nav-number">1.</span> <span class="nav-text">typeScript中的类</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#类的定义"><span class="nav-number">1.1.</span> <span class="nav-text">类的定义</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#ts中实现继承-extends、-super"><span class="nav-number">1.2.</span> <span class="nav-text">ts中实现继承 extends、 super</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#类里面的修饰符"><span class="nav-number">1.3.</span> <span class="nav-text">类里面的修饰符</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#protected：保护类型-在类里面、子类里面可以访问-，在类外部没法访问"><span class="nav-number">1.3.1.</span> <span class="nav-text">protected：保护类型  在类里面、子类里面可以访问 ，在类外部没法访问</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#private-：私有-在类里面可以访问，子类、类外部都没法访问"><span class="nav-number">1.3.2.</span> <span class="nav-text">private ：私有  在类里面可以访问，子类、类外部都没法访问</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#静态属性-静态方法"><span class="nav-number">1.4.</span> <span class="nav-text">静态属性 静态方法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#多态-父类定义一个方法不去实现，让继承它的子类去实现-每一个子类有不同的表现，多态属于继承"><span class="nav-number">1.5.</span> <span class="nav-text">多态:父类定义一个方法不去实现，让继承它的子类去实现,每一个子类有不同的表现，多态属于继承</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#typescript中的抽象类：它是提供其他类继承的基类，不能直接被实例化。"><span class="nav-number">1.6.</span> <span class="nav-text">typescript中的抽象类：它是提供其他类继承的基类，不能直接被实例化。</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2019 &mdash; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">TiX</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">访客</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">总访问</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      人次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/2.1.3/jquery.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fastclick/1.0.6/fastclick.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazyload/1.9.3/jquery.lazyload.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.ui.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
